//placa.js

function Placa (file,pontos)
{
this.img = new Image();
this.img.src= file;
this.loaded = false;
this.visible = true;
this.scale_x = 1
this.scale_y = 1


SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600


this.img.onload = function()
{
loaded = true; 
console.log("carregamento pela classe placa " + loaded);
};

   this.size_x = 100;
   this.size_y = 100;
   this.position_x = Math.floor((Math.random()*(SCREEN_WIDTH-this.size_x))); 
   this.position_y = Math.floor((Math.random()*(SCREEN_HEIGHT-this.size_y)));
   this.velocity_x = Math.floor((Math.random()*2)+1);
   this.velocity_y = Math.floor((Math.random()*2)+1);
   
   this.velocity_MAX = 15;
   
   
   this.draw=function()
   {
   	  		
   		screen.drawImage(this.img,
   						 this.position_x,
                         this.position_y);
           
      
   };
  
 
   this.update=function()
   {
   	
   	this.position_x += this.velocity_x;	

   	this.position_y += this.velocity_y;	
   	
   	this.Boundaries();
   	
   	
   	
   	
   };//fecha update
  
  
		this.Boundaries=function()
    {
    	if(this.position_x + this.size_x*this.scale_x < 0)
    	{
    		this.position_x = SCREEN_WIDTH;
    	}
    	
    	if(this.position_y + this.size_y*this.scale_y < 0)
    	{
    		this.position_y = SCREEN_HEIGHT;
    	}
    	
    	if(this.position_x > SCREEN_WIDTH)
    	{
    		this.position_x = - this.size_x*this.scale_x;
    	}
    	
    	if(this.position_y > SCREEN_HEIGHT)
    	{
    		this.position_y = - this.size_y*this.scale_y;
    	}
		 
    }

  
  
  
   
  }